Imports pixolut.BizBlox

Public Class CryptConnBuilder
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents txConnSrc As System.Windows.Forms.TextBox
    Friend WithEvents btEncrypt As System.Windows.Forms.Button
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents btCancel As System.Windows.Forms.Button
    Friend WithEvents txHardwareID As System.Windows.Forms.TextBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents cbUseMyHardware As System.Windows.Forms.CheckBox
    Friend WithEvents Label4 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(CryptConnBuilder))
        Me.btEncrypt = New System.Windows.Forms.Button
        Me.txConnSrc = New System.Windows.Forms.TextBox
        Me.btCancel = New System.Windows.Forms.Button
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.txHardwareID = New System.Windows.Forms.TextBox
        Me.Label2 = New System.Windows.Forms.Label
        Me.cbUseMyHardware = New System.Windows.Forms.CheckBox
        Me.Label4 = New System.Windows.Forms.Label
        Me.SuspendLayout()
        '
        'btEncrypt
        '
        Me.btEncrypt.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.btEncrypt.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btEncrypt.Location = New System.Drawing.Point(368, 176)
        Me.btEncrypt.Name = "btEncrypt"
        Me.btEncrypt.Size = New System.Drawing.Size(144, 23)
        Me.btEncrypt.TabIndex = 0
        Me.btEncrypt.Text = "Encrypt to Clipboard"
        '
        'txConnSrc
        '
        Me.txConnSrc.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.txConnSrc.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txConnSrc.Location = New System.Drawing.Point(16, 40)
        Me.txConnSrc.Name = "txConnSrc"
        Me.txConnSrc.Size = New System.Drawing.Size(576, 20)
        Me.txConnSrc.TabIndex = 1
        Me.txConnSrc.Text = ""
        '
        'btCancel
        '
        Me.btCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.btCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btCancel.Location = New System.Drawing.Point(528, 176)
        Me.btCancel.Name = "btCancel"
        Me.btCancel.TabIndex = 0
        Me.btCancel.Text = "Cancel"
        '
        'Label1
        '
        Me.Label1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Label1.Location = New System.Drawing.Point(16, 24)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(208, 16)
        Me.Label1.TabIndex = 3
        Me.Label1.Text = "Source Connection String"
        '
        'Label3
        '
        Me.Label3.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Label3.Location = New System.Drawing.Point(304, 72)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(288, 16)
        Me.Label3.TabIndex = 3
        Me.Label3.Text = "Paste the encrypted code to your config file."
        Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'txHardwareID
        '
        Me.txHardwareID.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.txHardwareID.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txHardwareID.Location = New System.Drawing.Point(192, 120)
        Me.txHardwareID.Name = "txHardwareID"
        Me.txHardwareID.Size = New System.Drawing.Size(216, 20)
        Me.txHardwareID.TabIndex = 1
        Me.txHardwareID.Text = ""
        '
        'Label2
        '
        Me.Label2.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Label2.Location = New System.Drawing.Point(16, 122)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(176, 16)
        Me.Label2.TabIndex = 3
        Me.Label2.Text = "Hardware ID to use for Encryption"
        Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'cbUseMyHardware
        '
        Me.cbUseMyHardware.Checked = True
        Me.cbUseMyHardware.CheckState = System.Windows.Forms.CheckState.Checked
        Me.cbUseMyHardware.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.cbUseMyHardware.Location = New System.Drawing.Point(416, 118)
        Me.cbUseMyHardware.Name = "cbUseMyHardware"
        Me.cbUseMyHardware.Size = New System.Drawing.Size(192, 24)
        Me.cbUseMyHardware.TabIndex = 4
        Me.cbUseMyHardware.Text = "Use this computer's Hardware ID"
        '
        'Label4
        '
        Me.Label4.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Label4.ForeColor = System.Drawing.Color.LightCoral
        Me.Label4.Location = New System.Drawing.Point(24, 144)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(440, 40)
        Me.Label4.TabIndex = 3
        Me.Label4.Text = "TIP: Copy the hardware ID from the server which you are intending to run the BizB" & _
        "lox application when creating a connection string which is being run remotely. "
        '
        'CryptConnBuilder
        '
        Me.AcceptButton = Me.btEncrypt
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.Color.White
        Me.CancelButton = Me.btCancel
        Me.ClientSize = New System.Drawing.Size(610, 207)
        Me.ControlBox = False
        Me.Controls.Add(Me.txHardwareID)
        Me.Controls.Add(Me.cbUseMyHardware)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.btEncrypt)
        Me.Controls.Add(Me.btCancel)
        Me.Controls.Add(Me.txConnSrc)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label4)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "CryptConnBuilder"
        Me.ShowInTaskbar = False
        Me.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Encrypt SQL Connection String"
        Me.TopMost = True
        Me.ResumeLayout(False)

    End Sub

#End Region


    Private Sub btEncrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btEncrypt.Click
        Clipboard.SetDataObject(DSNManager.EncryptConnectionString(Me.txConnSrc.Text, Me.txHardwareID.Text))
        Me.Hide()
    End Sub

    Private Sub btCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btCancel.Click
        Me.Hide()
    End Sub

    Private Sub CryptConnBuilder_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.txHardwareID.Text = HardwareID.SystemHash
    End Sub

    Private Sub cbUseMyHardware_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbUseMyHardware.CheckedChanged
        If Me.cbUseMyHardware.Checked Then
            Me.txHardwareID.Text = HardwareID.SystemHash
            Me.txHardwareID.ReadOnly = True
        Else
            Me.txHardwareID.ReadOnly = False
        End If
    End Sub
End Class
